	
	
	var memberTable = function(){
		return matchTable('#datatables','/lecture/getNotChooseMemberPageData.do',listArr,function(obj){
			obj.memberName = $("#memberName").val();
			obj.enName = $("#enName").val();
			obj.custType = $("#custType").val();
			obj.sex = $("#sex").val();
			obj.mobile = $("#mobile").val();
			obj.wechatNum = $("#wechatNum").val();
			obj.lectureNotice = $("#lectureNotice").val();
			obj.lectureId = $("#lectureId").val();
		},true);
	} 
	
	

$(function(){
	
	memberTable();
	
	getSelectLectrueType("#lectureType");
	
	getSelectCustType("#custType");
	
	//查询
	$(".vdrallsearch").on('click',function(){
		memberTable().draw();
	});
	
	//重置
	$(".resetSearchForm").on('click',function(){
		$("#custType").html('<option value="">请选择客户种类</option>').trigger("change");
        $("#excel")[0].reset();
	});
    
  //单击行选中事件
    $('#datatables tbody').on('click', 'tr', function () {
        var table = $('#datatables').DataTable();
        var data = table.row(this).data();
        if ($(this).hasClass('selected')) {
            $(this).removeClass('selected');
            $('#check' + data.id).prop("checked", false);
        } else {
            $(this).addClass('selected');
            $('#check' + data.id).prop("checked", true);
        }
    });
    

    
  //全选事件
    $(".checkall").click(function () {
        var check = $(this).prop("checked");
        $(".checkchild").prop("checked", check);
        var cells = new Array();
        $('#datatables tbody tr').each(function () {
            if (check) {
                $(this).addClass('selected');
            } else {
                $(this).removeClass('selected');
            }
        });
    });
    
    
    
  //参与讲座
    $(".joinLectrue").on('click', function () {
        var c_tIds="";
        var choose_a = $("#datatables tbody :checkbox:checked");
        $.each(choose_a, function (n) {
            if (n == 0) {
            	c_tIds = choose_a.eq(n).val();
            } else {
            	c_tIds = c_tIds + "," + choose_a.eq(n).val();
            }
        })
        if (c_tIds == undefined || $.trim(c_tIds) == "") {
        	layer.msg("请选择一条记录！");
            return false;
        }
        var lectureType = $('#lectureType').val();
        if(lectureType == ''){
        	layer.msg("请选择参与方式！");
            return false;
        }
        if (confirm("确认勾选的会员参与讲座吗？")) {
        	$.ajax({
        		url : webroot + '/lecture/saveMemberLecture.do',
        		data : {'ids':c_tIds,'lectureId':$("#lectureId").val(),'lectureType':lectureType},
        		type : 'post',
        		dataType : 'json',
        		success : function(result){
        			layer.msg(result.msg);
        			if(result.type=='2'){
        				memberTable().draw();
        			}
        			
        		}
        	});
        }
    });
});



